default_platform(:mac)

key_id = ENV.fetch("APP_STORE_KEY_ID")
issuer_id = ENV.fetch("APP_STORE_ISSUER_ID")
key_content = ENV.fetch("APP_STORE_KEY")
git_private_key = ENV.fetch("MATCH_GIT_PRIVATE_KEY")

platform :mac do
  desc "Signs app on CI"
  lane :certificates do
    setup_ci if is_ci

    app_store_connect_api_key(
      key_id: key_id,
      issuer_id: issuer_id,
      key_content: key_content,
      in_house: false,
    )

    match(
      type: "development",
      git_private_key: git_private_key,
      app_identifier: ["pl.leancode.patrol.*"]
    )

    update_code_signing_settings(
      use_automatic_signing: false,
      targets: ["Runner", "RunnerUITests"],
      build_configurations: ["Release"],
      profile_uuid: ENV["sigh_pl.leancode.patrol.*_development"],
    )
  end
end
